// This is the main.js file. Import global CSS and scripts here.
// The Client API can be used here. Learn more: gridsome.org/docs/client-api
import Vue from 'vue'

import ElementUI from 'element-ui'
import 'element-ui/lib/theme-chalk/index.css'
Vue.use(ElementUI)

import Vant from 'vant'
import 'vant/lib/index.css'
Vue.use(Vant)

import 'mavon-editor/dist/css/index.css'
import 'mavon-editor/dist/markdown/github-markdown.min.css'

import DefaultLayout from '~/layouts/Default.vue'

Vue.filter('utcToLocal', function (time) {
  let formatNum = (num)=>{
    return num>=10?num:('0'+num)
  }
  let arr = time.split(/[^0-9]/)
  let worldDate = new Date(arr[0], arr[1] - 1, arr[2], arr[3], arr[4], arr[5])
  let localDate = new Date(worldDate.getTime() + 8 * 60 * 60 * 1000)
  return formatNum(localDate.getFullYear()) + "-"
      + formatNum((localDate.getMonth() + 1)) + "-"
      + formatNum(localDate.getDate()) + " "
      + formatNum(localDate.getHours()) + ":"
      + formatNum(localDate.getMinutes()) + ":"
      + formatNum(localDate.getSeconds())
})

export default function (Vue, { router, head, isClient }) {
  // Set default layout as a global component
  Vue.component('Layout', DefaultLayout)
}
